package com.szcinda.controller;

import com.szcinda.repository.OperationLog;
import com.szcinda.service.PageResult;
import com.szcinda.service.dto.log.LogQueryDto;
import com.szcinda.service.dto.log.LogService;
import com.szcinda.service.dto.log.OperationLogDto;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("log")
public class LogController {

    private final LogService logService;

    public LogController(LogService logService) {
        this.logService = logService;
    }

    @PostMapping("query")
    public PageResult<OperationLog> query(@RequestBody LogQueryDto queryDto) {
        return logService.query(queryDto);
    }

    @GetMapping("userLog/{userId}/{orgId}")
    public Result<List<OperationLogDto>> getUserLog(@PathVariable String userId, @PathVariable String orgId){
        return Result.success(logService.getByUserId(userId, orgId));
    }
}
